package com.lan.app.interceptot;

import com.lan.support.convert.StringConverter;
import com.lan.support.convert.StringToDateConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册拦截器
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册自定义拦截器，添加拦截路径和排除拦截路径
        //.addPathPatterns("/*").excludePathPatterns("api/login")
        registry.addInterceptor(new LoginInterceptor());
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        "*.js", "*.css", "*.png", "*.ico"
//        registry.addResourceHandler("/**").addResourceLocations("classpath:/view/");
    }

    @Bean
    public StringToDateConverter stringToDateConverter() {
        return new StringToDateConverter();
    }

    @Bean
    public StringConverter stringToStringConverter() {
        return new StringConverter();
    }

}
